import 'package:get/get.dart';

class LoginPageController extends GetxController {
  var passwdList = [
    {0: false},
    {1: false},
    {2: false},
    {3: false},
    {4: false},
    {5: false},
  ];

  var clickIndex = 0;

  String loginPasswd = "";

  static LoginPageController get lc => Get.find();

  void updatePasswd(String num) {
    // print("leng==" + passwdList.length.toString());
    // print("clickIndex1===" + clickIndex.toString());
    if (clickIndex <= 5) {
      loginPasswd += num;
      passwdList[clickIndex][clickIndex] = !passwdList[clickIndex][clickIndex];
      clickIndex += 1;
    }
    // print("clickIndex2===" + clickIndex.toString());
    // print(passwdList);
    update();
  }

  void cleanPasswd() {
    loginPasswd = "";
    for (int i = 0; i <= 5; i++) {
      passwdList[i][i] = false;
    }
    clickIndex = 0;
    update();
  }

  void backPasswd() {
    var pStrLen = loginPasswd.length;
    print(pStrLen);
    if (pStrLen >= 0) {
      loginPasswd = loginPasswd.substring(0, pStrLen - 1);
      print(loginPasswd);
      passwdList[clickIndex][clickIndex] = !passwdList[clickIndex][clickIndex];
      if (clickIndex > 0) clickIndex -= 1;
      update();
    }
  }
}
